<!--title-->
<div class="mnav1">
	<div class="m_nav">
		<div class="nav_left">
			<em class="home_icon"><?=$this->sys_name?></em><span>&nbsp;&gt;&nbsp;</span><font><?=$this->title?></font>
		</div>
	</div>
</div>

<div class="content-table2">
<div class="content-table-title"><?=$this->title?></div>
<div class="form-edit-task">

<form action="/contracts/add-contract-log-submit" method="post" name="form1" onsubmit="submitform(this);return false;">
<table border="0" width="100%">
	<tr>
		<td align="right">金额：</td>
		<td align="left">&nbsp;<input type="text" placeholder="金额" name="avalue" id="avalue" onkeyup='num(this)' style="width: 100px"><font color="red"> *</font></td>
	</tr>
	<tr>
		<td align="right">发票号码：</td>
		<td align="left">&nbsp;<input type="text" placeholder="发票号码" name="invoice" id="invoice" style="width: 300px" <?php if($this->invoice_num):?>value="<?=$this->invoice_num?>"<?php endif;?>><?php if($this->is_applied && !$this->invoice_num):?><font color="green"> (已申请开票)</font><?php elseif(!$this->is_applied):?><font color="red"> * <input type="button" value="未开票，请先申请开票" onclick="window.location.href='/contracts/invoice-apply/contract_id/<?=$this->contract_id?>/type/2'"></font><?php endif;?></td>
	</tr>
	<tr>
		<td align="right">备注：</td>
		<td align="left">&nbsp;<input type="text" placeholder="备注" name="tips" id="tips" style="width: 500px"></td>
	</tr>
	<tr>
		<td align="right">回款日期：</td>
		<td align="left">&nbsp;<input type="text" name="pay_date" id="pay_date" placeholder="回款日期" value="<?=date("Y-m-d")?>" style="width: 100px"><font color="red"> *</font></td>
	</tr>
	<?php if($this->is_applied):?>
	<tr>
		<td colspan="2" align="center"><br><br><input type="hidden" name="contract_id" value="<?=$this->contract_id?>" /><input type="button" class="buttonlong" value="提交" onclick="submitform();return false;" /></td>
	</tr>
	<?php endif;?>
</table>
<br /><br />
</form>
</div>
<br/><br/>
</div>

<script>
function num(th){
	th.value = th.value.replace(/[^\d\.]*$/g, '');
}

$(function() {
	$( "#pay_date" ).datepicker({ dateFormat: 'yy-mm-dd' });
});

function submitform() 
{
	if( document.form1.avalue.value.length == 0 )
	{
		alert("金额不能为空。");
		return false;
	}else if(document.form1.avalue.value > <?=$this->remaining_value?>)
	{
		alert("回款金额不可大于当前剩余回款金额：<?=$this->remaining_value?>元");
		return false;
	}
	
	form1.submit();
}
</script>
